<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "../utils/rule";
import { FormProps } from "../utils/types";
import { usePublicHooks } from "../../hooks";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    title: "新增",
    higherDeptOptions: [],
    dic_id: 0,
    label: "",
    value: "",
    value2: "",
    status: 1,cateList:[]
  })
});
const ruleFormRef = ref();
const { switchStyle } = usePublicHooks();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-row :gutter="30">
      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="值编号" prop="label">
          <el-input
            v-model="newFormInline.label"
            clearable
            placeholder="请输入值编号，值编号唯一"
          />
        </el-form-item>
      </re-col>
      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="值名称" prop="value">
          <el-input
            v-model="newFormInline.value"
            clearable
            placeholder="请输入值名称"
          />
        </el-form-item>
      </re-col>

      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="附加信息" prop="value2">
          <el-input
            v-model="newFormInline.value2"
            clearable
            placeholder="请输入附加信息"
          />
        </el-form-item>
      </re-col>


      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="所属分类" prop="dic_id">
          <el-select
            v-model="newFormInline.dic_id"
            placeholder="请选择所属分类"
            class="w-full"
            clearable
          >
            <el-option
              v-for="(item, index) in newFormInline.cateList"
              :key="index"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

        </el-form-item>
      </re-col>
      <re-col
        :value="24"
        :xs="24"
        :sm="24"
      >
        <el-form-item label="状态">
          <el-switch
            v-model="newFormInline.status"
            inline-prompt
            :active-value="1"
            :inactive-value="0"
            active-text="启用"
            inactive-text="停用"
            :style="switchStyle"
          />
        </el-form-item>
      </re-col>

    </el-row>
  </el-form>
</template>
